using ASP;
using HoWave.Common;
using HoWave.Data.Bll;
using HoWave.Data.Model;
using HoWave.Web;
using HoWave.Web.Shop.Member;
using System;
using System.Data;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
public class Member_JXC_CheckAccountAoucher : Member, IRequiresSessionState
{
	private string linkHead = "";
	private string beforeurl = "CheckAccountAoucher.aspx?1=1";
	private int infoID = 0;
	protected Literal ltrTitle;
	protected TextBox txtSearchBeginDate;
	protected TextBox txtSearchEndDate;
	protected TextBox txtSearchInfoNumber;
	protected Button btnSearch;
	protected GridView gvManage;
	protected Literal ltrPagePanel;
	protected Panel pnlManage;
	protected Label lblAccountANumber;
	protected Label lblAccountACount;
	protected Label lblInputer;
	protected Label lblInputDate;
	protected Label lblAccountAExplain;
	protected Label lblCauditName;
	protected Label lblCauditDate;
	protected HtmlTableRow tr_IsCaudit;
	protected Label lblAccountName;
	protected Label lblAccountDate;
	protected HtmlTableRow tr_IsAccount;
	protected GridView gvItem;
	protected Button btnCancle;
	protected Panel pnlDetail;
	public int InfoID
	{
		get
		{
			if (base.Request.QueryString["InfoID"] != null)
			{
				this.infoID = Convert.ToInt32(base.Request.QueryString["InfoID"].Trim());
			}
			return this.infoID;
		}
		set
		{
			this.infoID = value;
		}
	}
	protected DefaultProfile Profile
	{
		get
		{
			return (DefaultProfile)this.Context.Profile;
		}
	}
	protected global_asax ApplicationInstance
	{
		get
		{
			return (global_asax)this.Context.ApplicationInstance;
		}
	}
	protected void Page_Load(object sender, EventArgs e)
	{
		if (!base.IsPostBack)
		{
			if (!base.OwnerPowerFinancemanage(base.user.UserID))
			{
				base.WriteRightErrMsg();
			}
			this.ShowPanelDisplay(base.ActionTabInfo);
		}
	}
	protected void ShowPanelDisplay(string DisplayName)
	{
		if (DisplayName != null)
		{
			if (DisplayName == "checkinfo")
			{
				this.pnlManage.Visible = false;
				this.pnlDetail.Visible = true;
				if (this.InfoID > 0)
				{
					this.InitPage();
				}
				else
				{
					this.WriteErrMsg("", "没有凭证信息！", "CheckAccountAoucher.aspx");
				}
				return;
			}
		}
		this.pnlManage.Visible = true;
		this.pnlDetail.Visible = false;
		this.BindData();
	}
	protected void InitPage()
	{
		HoWave.Data.Model.AccountAoucher model = BLLInstance.BllAccountAoucher.GetModel(this.InfoID);
		if (model != null)
		{
			this.lblAccountANumber.Text = model.AccountANumber;
			this.lblInputDate.Text = model.InputDate.ToString();
			this.lblInputer.Text = model.Inputer;
			this.lblAccountACount.Text = model.AccountACount.ToString();
			this.lblAccountAExplain.Text = model.AccountAExplain;
			string text = model.IsCaudit.ToString();
			if (text.ToLower().Trim() == "true")
			{
				this.lblCauditName.Text = model.CauditName;
				this.lblCauditDate.Text = model.CauditDate.ToString();
				this.tr_IsCaudit.Visible = true;
			}
			string text2 = model.IsAccount.ToString();
			if (text2.ToLower().Trim() == "true")
			{
				this.lblAccountName.Text = model.AccountName;
				this.lblAccountDate.Text = model.AccountDate.ToString();
				this.tr_IsAccount.Visible = true;
			}
		}
		DataTable dataSource = BLLInstance.BllAccountAoucherItem.GetList(" AccountAoucherID=" + this.infoID).Tables[0];
		this.gvItem.DataSource = dataSource;
		this.gvItem.DataBind();
	}
	public string GetSubjcetName(object obj)
	{
		string result = "";
		if (!string.IsNullOrEmpty(obj.ToString()))
		{
			result = BLLInstance.BllAccountSubject.GetSubjcetNameBySubjectID(obj.ToInt32(new int[0]));
		}
		return result;
	}
	public string GetSubjcetMoney(object obj)
	{
		string result = "";
		if (!string.IsNullOrEmpty(obj.ToString()))
		{
			if (obj.ToDecimal2() > 0m)
			{
				result = obj.ToString();
			}
		}
		return result;
	}
	protected string GetQuery()
	{
		string text = " where OwnerID=" + base.user.UserID + " ";
		string text2 = Fetch.Get("BeginTime");
		if (!string.IsNullOrEmpty(text2))
		{
			this.txtSearchBeginDate.Text = text2;
		}
		else
		{
			text2 = this.txtSearchBeginDate.Text;
		}
		if (!string.IsNullOrEmpty(text2))
		{
			text = text + " and DATEDIFF(DD, InputDate,'" + text2 + "')<=0";
			this.linkHead = this.linkHead + "&BeginTime=" + text2;
		}
		string text3 = Fetch.Get("EndTime");
		if (!string.IsNullOrEmpty(text3))
		{
			this.txtSearchEndDate.Text = text3;
		}
		else
		{
			text3 = this.txtSearchEndDate.Text;
		}
		if (!string.IsNullOrEmpty(text3))
		{
			if (!string.IsNullOrEmpty(text2))
			{
				if (Convert.ToDateTime(text2) > Convert.ToDateTime(text3))
				{
					this.WriteErrMsg("", Language.Get("Common/DateTimeErr"), "");
				}
			}
			text = text + "and DATEDIFF(DD, InputDate,'" + text3 + "')>=0";
			this.linkHead = this.linkHead + "&EndTime=" + text3;
		}
		string text4 = Fetch.Get("AccountANumber");
		if (!string.IsNullOrEmpty(text4))
		{
			this.txtSearchInfoNumber.Text = text4;
		}
		else
		{
			text4 = this.txtSearchInfoNumber.Text;
		}
		if (!string.IsNullOrEmpty(text4))
		{
			text = text + " and AccountANumber like '%" + text4 + "%'";
			this.linkHead = this.linkHead + "&AccountANumber=" + text4;
		}
		return text;
	}
	private string GetQueryByOrder()
	{
		return "order by AccountAoucherID desc";
	}
	public void BindData()
	{
		string query = this.GetQuery();
		string queryByOrder = this.GetQueryByOrder();
		int num = this.gvManage.PageIndex;
		if (Fetch.Get("pageindex") != null)
		{
			num = Convert.ToInt32(Fetch.GetID("pageindex").ToString());
			if (num == 0)
			{
				num = 1;
			}
		}
		DataTable listAccountAoucherItemSubjcet = BLLInstance.BllAccountAoucher.GetListAccountAoucherItemSubjcet(query);
		DataTable dataTable = BLLInstance.BllAccountAoucher.GetNewDataSet(listAccountAoucherItemSubjcet, true).Tables[0];
		int pageSize = this.gvManage.PageSize;
		int count = dataTable.Rows.Count;
		this.gvManage.DataSource = CurrPageLinks.instance.GetPagedTable(dataTable, num, pageSize);
		this.gvManage.DataBind();
		for (int i = 0; i < this.gvManage.Rows.Count; i++)
		{
			HiddenField hiddenField = (HiddenField)this.gvManage.Rows[i].FindControl("hfIsCaudit");
			LinkButton linkButton = (LinkButton)this.gvManage.Rows[i].FindControl("lkbtnOK");
			LinkButton linkButton2 = (LinkButton)this.gvManage.Rows[i].FindControl("lkbtnCancle");
			if (hiddenField != null)
			{
				if (!string.IsNullOrEmpty(hiddenField.Value))
				{
					if (hiddenField.Value.Trim() == "<span style='color:Green;'>√</span>")
					{
						linkButton2.Text = hiddenField.Value;
						linkButton.Enabled = false;
					}
					else
					{
						linkButton.Text = hiddenField.Value;
						linkButton2.Enabled = false;
					}
				}
			}
			HiddenField hiddenField2 = (HiddenField)this.gvManage.Rows[i].FindControl("hfAccountAoucherID");
			HyperLink hyperLink = (HyperLink)this.gvManage.Rows[i].FindControl("hlDetails");
			if (hiddenField2 != null)
			{
				if (string.IsNullOrEmpty(hiddenField2.Value))
				{
					hyperLink.Visible = false;
				}
			}
		}
		string url = this.beforeurl + this.linkHead + "&pageindex";
		this.ltrPagePanel.Text = CurrPageLinks.instance.CurrPageLinkStr(num, pageSize, count, "条记录&nbsp;每页" + pageSize + "条记录&nbsp;", url, true);
	}
	protected void gridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
	{
		this.gvManage.PageIndex = e.NewPageIndex;
		this.BindData();
	}
	protected void gridView_RowDataBound(object sender, GridViewRowEventArgs e)
	{
		if (e.Row.RowType == DataControlRowType.DataRow)
		{
			e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#E7EDFE'");
			e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c;");
		}
	}
	protected void Button_Command(object sender, CommandEventArgs e)
	{
		string text = this.beforeurl + this.linkHead + "&pageindex";
		string commandName = e.CommandName;
		string str = e.CommandArgument.ToString();
		base.Response.Redirect("AccountAoucherInfo.aspx?Action=editinfo&InfoID=" + str);
	}
	protected void btnSearch_Click(object sender, EventArgs e)
	{
		this.BindData();
	}
	public void btnCancle_Click(object sender, EventArgs e)
	{
		base.Response.Redirect("CheckAccountAoucher.aspx");
	}
}
